package Model.Cages;

import Model.Animals.Animal;
import Model.Entity;
import java.util.ArrayList;

/**
 *
 * @author HOANG TRUONG DINH
 */
public abstract class Cage extends Entity {

    ArrayList<Animal> animals;
    int cost;
    int level;

    public Cage(int capacity, String ref, int x, int y) {
        super(ref, x, y);
        animals = new ArrayList<Animal>();
        cost = 0;
        level = 1;
    }

    public abstract boolean addAnimal(Animal a);

    public boolean removeAnimal(Animal a) {
        animals.remove(a);
        return animals.contains(a);
    }
    
    public boolean removeAllAnimal(){
        return animals.removeAll(animals);
    }

    public double upgradeCost() {
        if (level < 3) {
            return cost * 0.8;
        } else {
            return -1;
        }
    }

    public void upgrade() {
        if (level < 3) {
            level++;
            cost *= 0.8;
        }
    }

    public void upgradeAnimal(Animal a) {
        a.upgrade();
    }

    public double calCost() {
        return cost;
    }
}
